package com.jeff.android.lab.architecture.arouter.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.jeff.android.lab.BaseActivity;
import com.jeff.android.lab.R;
import com.jeff.android.lab.commonlib.router.Constant;
import com.jeff.utils.ToastUtil;

/**
 * @author: duff
 * @date: 2019/3/11
 * @since: 1.0.0
 */
@Route(path = Constant.ACTIVITY_URL_ONE)
public class OneActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_one);
        setTitle("One");

        findViewById(R.id.btn_next).setOnClickListener(
                v -> ARouter.getInstance()
                        .build(Constant.ACTIVITY_URL_TWO)
                        .navigation(this, 100));
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 100 && data != null) {
            String from = data.getStringExtra("from");
            ToastUtil.show(this, from);
        }
    }

}
